import React, { PureComponent,Fragment } from 'react';
import {Form, Select} from "antd";
const FormItem = Form.Item;
const Option = Select.Option;
// @Form.create()
export default class AreaMap extends PureComponent {
  constructor(props) {
    super(props);
    this.state = {
      company_ids: this.props.searchParams.company_ids,
    };
  }
  componentDidMount() {

  }
  render() {
    console.log(' this.state.company_ids', this.state.company_ids)
    const {searchParams,getFieldDecorator}=this.props
    return (
      <Fragment >
        <FormItem label="分区" style={{color:this.props.labelColor?this.props.labelColor:'#eee'}}>
          {getFieldDecorator('company_ids', {
            initialValue: searchParams.company_ids,
          })(
            <Select style={{ width: '120px' }}   onChange={(value, option)=>{
              console.log(value)
              this.setState({
                company_ids:value
              },function (){
                this.props.form.setFieldsValue({
                  company_id:''
                })
              })


            }}>
              <Option  disabled={sessionStorage.getItem('company_sign')!=='all'} value={'all'}>全部</Option>
              <Option  disabled={sessionStorage.getItem('company_sign')==='w'} value={'e'}>东区事业部</Option>
              <Option disabled={sessionStorage.getItem('company_sign')==='e'} value={'w'}>西区事业部</Option>
            </Select>,
          )}
        </FormItem>
        {
          this.state.company_ids === 'e' &&
          <FormItem label="二级分区">
            {getFieldDecorator('company_id', {
              initialValue: searchParams.company_id,
            })(
              <Select style={{width: '120px'}} allowClear>
                    <Option value={'648923212503085057'}>七泉湖镇</Option>
                    <Option value={'648922585010020353'}>葡萄镇</Option>
                    <Option value={'648923080231505921'}>胜金乡</Option>
                    <Option value={'648923024594059265'}>恰特喀勒乡</Option>
                    <Option value={'648923139174064129'}>二堡乡</Option>
                    <Option value={'648922657202384897'}>三堡乡</Option>

              </Select>,
            )}
          </FormItem>
        }
        {
          this.state.company_ids === 'w' &&
          <FormItem label="二级分区">
            {getFieldDecorator('company_id', {
              initialValue: searchParams.company_id,
            })(
              <Select style={{width: '120px'}} allowClear>
                <Option value={'647076256457691137'}>老城区</Option>
                <Option value={'648923288201883648'}>大沿河</Option>
                <Option value={'648922772206006272'}>亚尔乡</Option>
                <Option value={'648922723606605824'}>艾丁湖</Option>

              </Select>,
            )}
          </FormItem>
        }
        {
          (this.state.company_ids === ''||this.state.company_ids === 'all') &&
          <FormItem label="二级分区">
            {getFieldDecorator('company_id', {
              initialValue: searchParams.company_id,
            })(
              <Select style={{width: '120px'}} allowClear>
                <Option value={'647076256457691137'}>老城区</Option>
                <Option value={'648923288201883648'}>大沿河</Option>
                <Option value={'648922772206006272'}>亚尔乡</Option>
                <Option value={'648922723606605824'}>艾丁湖</Option>
                <Option value={'648923212503085057'}>七泉湖镇</Option>
                <Option value={'648922585010020353'}>葡萄镇</Option>
                <Option value={'648923080231505921'}>胜金乡</Option>
                <Option value={'648923024594059265'}>恰特喀勒乡</Option>
                <Option value={'648923139174064129'}>二堡乡</Option>
                <Option value={'648922657202384897'}>三堡乡</Option>

              </Select>,
            )}
          </FormItem>
        }
        {/*{
          this.state.area === '' &&
          <FormItem label="二级分区">
            {getFieldDecorator('company_id', {
              initialValue: searchParams.company_id,
            })(
              <Select style={{width: '120px'}} allowClear>
              </Select>,
            )}
          </FormItem>
        }*/}
      </Fragment>
    );
  }
}
